package com.qk.management.service.impl;

import com.qk.entity.FileCleanStatus;
import com.qk.management.mapper.FileCleanStatusMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Service
public class FileCleanStatusService {

    @Autowired
    private FileCleanStatusMapper fileCleanStatusMapper;

    /**
     * 获取上次清理时间
     */
    public LocalDateTime getLastCleanTime() {
        FileCleanStatus status = fileCleanStatusMapper.selectLastStatus();
        return status != null ? status.getCleanTime() : null;
    }

    /**
     * 更新清理时间
     */
    public void updateLastCleanTime(LocalDateTime cleanTime) {
        FileCleanStatus status = new FileCleanStatus();
        status.setCleanTime(cleanTime);
        status.setUpdateTime(LocalDateTime.now());
        fileCleanStatusMapper.insert(status);
    }
}
